package com.smallyang.controller;

import com.smallyang.domain.ResponseResult;
import com.smallyang.domain.dto.FriendDTO;
import com.smallyang.domain.entity.Link;
import com.smallyang.domain.vo.FriendBackVO;
import com.smallyang.domain.vo.LinkVo;
import com.smallyang.domain.vo.PageVo;
import com.smallyang.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 杨森
 * @description:
 * @date 2023年05月21日 11:08
 */
@RestController
@RequestMapping("/content/link")
public class BcLinkController {
    @Autowired
    private LinkService linkService;

    @GetMapping("/list")
    public ResponseResult<PageVo> listFriendBackVO(Integer pageNum, Integer pageSize, FriendDTO friendDTO) {
        return linkService.listFriendBackVO(pageNum,pageSize,friendDTO);
    }

    @PostMapping
    public ResponseResult addFriend(@RequestBody Link link){
        linkService.save(link);
        return ResponseResult.okResult();
    }

    @GetMapping("/{id}")
    public ResponseResult getInfo(@PathVariable("id") Long id){
        Link link = linkService.getById(id);
        return ResponseResult.okResult(link);
    }

    @PutMapping
    public ResponseResult updateFriend(@RequestBody Link link) {
        linkService.updateById(link);
        return ResponseResult.okResult();
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable List<Long> id){
        linkService.removeByIds(id);
        return ResponseResult.okResult();
    }
}
